import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RequireVO, RequireForm, RequireQuery } from '@/api/pm/require/types';

/**
 * 查询需求列表
 * @param query
 * @returns {*}
 */

export const listRequire = (query?: RequireQuery): AxiosPromise<RequireVO[]> => {
  return request({
    url: '/pm/require/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询需求详细
 * @param id
 */
export const getRequire = (id: string | number): AxiosPromise<RequireVO> => {
  return request({
    url: '/pm/require/' + id,
    method: 'get'
  });
};

/**
 * 新增需求
 * @param data
 */
export const addRequire = (data: RequireForm) => {
  return request({
    url: '/pm/require',
    method: 'post',
    data: data
  });
};

/**
 * 修改需求
 * @param data
 */
export const updateRequire = (data: RequireForm) => {
  return request({
    url: '/pm/require',
    method: 'put',
    data: data
  });
};

/**
 * 删除需求
 * @param id
 */
export const delRequire = (id: string | number | Array<string | number>) => {
  return request({
    url: '/pm/require/' + id,
    method: 'delete'
  });
};
